package org.moonshiner.controller.svn;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;


public class SVNRepositoryProvider {

	public static final String BEAN_NAME = "svnRepositoryProvider";
	
	private SVNRepository repository;
	
	public SVNRepositoryProvider() {
	}

	public SVNRepository initRepository(String repositoryURL)
			throws SVNException {

		DAVRepositoryFactory.setup();

		SVNURL svnurl = null;
		SVNRepository repository = null;

		svnurl = SVNURL.parseURIDecoded(repositoryURL);
		repository = SVNRepositoryFactory.create(svnurl);

		setRepository(repository);
		
		return repository;
	}

	public SVNRepository getRepository() {
		return repository;
	}

	private void setRepository(SVNRepository repository) {
		this.repository = repository;
	}

	
	
}
